/******************************************************************************
Paper: The Impact of Welfare on Intergroup Relations
Author: Akshay Dixit


CPHS: This .do file imports CPHS .csv files into Stata.

CPHS data is typically downloaded in individual zip files.

Ensure that the following data has been downloaded and unzipped in the cphs folder, 
prior to running this .do file:
	1. Member income - 20170531 to 20190430
	2. Household income - 20170531 to 20190430
	3. Aspirational India - 20170501_20170831 to 20190101_20190430
	4. Consumption pyramids - 20170531 to 20190430
******************************************************************************/

clear all
gl data_cmie "$identity/data/cphs"

******************************************************************************

*** Import all .csv files and save as .dta files ***	

local datafiles: dir "$data_cmie" files "*.csv"
foreach datafile of local datafiles {
	
	import delimited using "$data_cmie/`datafile'", varnames(1) clear
	
	* Keep Telangana because it is the main state of interest
	* Keep neighboring states for 8_cphs_bordering_districts.do
	keep if state == "Telangana" | state == "Andhra Pradesh" | state == "Maharashtra" | state == "Chhattisgarh" | state == "Karnataka"
	
	local outfile = subinstr("`datafile'",".csv","",.)
    save "$data_cmie/`outfile'", replace
    erase "$data_cmie/`datafile'"	//Delete .csv files
	
}

******************************************************************************

clear


